package com.ruoyi.web.controller.market.special;

import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.special.domain.SpecialCostomCountInfo;
import com.ruoyi.special.service.ISpecialCostomCountInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.wapper.SpecialCostomCountInfoWapper;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机构统计Controller
 * 
 * @author ruoyi
 * @date 2024-08-30
 */
@Controller
@RequestMapping("/special/countInfo")
public class SpecialCostomCountInfoController extends BaseController
{
    private String prefix = "special/countInfo";

    @Autowired
    private ISpecialCostomCountInfoService specialCostomCountInfoService;

    @RequiresPermissions("special:countInfo:view")
    @GetMapping()
    public String countInfo()
    {
        return prefix + "/countInfo";
    }

    /**
     * 查询机构统计列表
     */
    @RequiresPermissions("special:countInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SpecialCostomCountInfo specialCostomCountInfo)
    {

        Map<String, Object> totalMap = specialCostomCountInfoService.selectSpecialCostomCountInfoTotaltMap(specialCostomCountInfo);

        startPage();
        List<Map<String, Object>> mapList = specialCostomCountInfoService.selectSpecialCostomCountInfoListMap(specialCostomCountInfo);

        mapList.add(0, totalMap);

        mapList = new SpecialCostomCountInfoWapper(mapList).wrap();
        return getDataTable(mapList);
    }

    /**
     * 导出机构统计列表
     */
    @RequiresPermissions("special:countInfo:export")
    @Log(title = "机构统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SpecialCostomCountInfo specialCostomCountInfo)
    {
        List<SpecialCostomCountInfo> list = specialCostomCountInfoService.selectSpecialCostomCountInfoList(specialCostomCountInfo);
        ExcelUtil<SpecialCostomCountInfo> util = new ExcelUtil<SpecialCostomCountInfo>(SpecialCostomCountInfo.class);
        return util.exportExcel(list, "机构统计数据");
    }

    /**
     * 新增机构统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存机构统计
     */
    @RequiresPermissions("special:countInfo:add")
    @Log(title = "机构统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SpecialCostomCountInfo specialCostomCountInfo)
    {
        return toAjax(specialCostomCountInfoService.insertSpecialCostomCountInfo(specialCostomCountInfo));
    }

    /**
     * 修改机构统计
     */
    @RequiresPermissions("special:countInfo:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SpecialCostomCountInfo specialCostomCountInfo = specialCostomCountInfoService.selectSpecialCostomCountInfoById(id);
        mmap.put("specialCostomCountInfo", specialCostomCountInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存机构统计
     */
    @RequiresPermissions("special:countInfo:edit")
    @Log(title = "机构统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SpecialCostomCountInfo specialCostomCountInfo)
    {
        return toAjax(specialCostomCountInfoService.updateSpecialCostomCountInfo(specialCostomCountInfo));
    }

    /**
     * 删除机构统计
     */
    @RequiresPermissions("special:countInfo:remove")
    @Log(title = "机构统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(specialCostomCountInfoService.deleteSpecialCostomCountInfoByIds(ids));
    }
}
